package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.bifang.module.base.common.vo.org.OrgTreeVO;
import com.bifang.module.base.common.vo.tree.TreeRetVO;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduFormEnroll.EduFormEnrollKeyVO;
import com.jwsoft.manager.common.vo.eduFormEnrollBase.EduFormEnrollBaseKeyVO;
import com.jwsoft.manager.common.vo.eduFormEnrollBase.EduFormEnrollBaseQueryVO;
import com.jwsoft.manager.common.vo.eduFormEnrollBase.EduFormEnrollBaseVO;
import com.jwsoft.manager.common.vo.eduFormEnrollParamsBase.EduFormEnrollParamsBaseVO;
import com.jwsoft.manager.common.vo.eduFormEnrollParamsBase.SaveFormEnrollParamsBaseVO;
import com.jwsoft.manager.core.integration.EduFormEnrollBaseIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 教育报名表单表模板网关
 *
 * @author zjl
 * @since 2024-04-12
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "教育报名表单表模板", description = "教育报名表单表模板")
public class EduFormEnrollBaseController {

    @Autowired
    public EduFormEnrollBaseIntegration eduFormEnrollBaseIntegration;

    @Operation(summary = "教育报名表单表模板分页查询",description = "教育报名表单表模板分页查询")
    @PostMapping(value = "/eduFormEnrollBase0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduFormEnrollBaseVO>> getList(@RequestBody @Validated EduFormEnrollBaseQueryVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.getList(vo));
    }

    @Operation(summary = "教育报名表单表模板根据主键查询详情",description = "教育报名表单表模板根据主键查询详情")
    @PostMapping(value = "/eduFormEnrollBase0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollBaseVO> getById(@RequestBody @Validated EduFormEnrollBaseKeyVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育报名表单表模板新增",description = "教育报名表单表模板新增")
    @PostMapping(value = "/eduFormEnrollBase0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollBaseVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduFormEnrollBaseVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育报名表单表模板修改",description = "教育报名表单表模板修改")
    @PostMapping(value = "/eduFormEnrollBase0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollBaseVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduFormEnrollBaseVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育报名表单表模板删除",description = "教育报名表单表模板删除")
    @PostMapping(value = "/eduFormEnrollBase0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduFormEnrollBaseKeyVO vo) {
        eduFormEnrollBaseIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Operation(summary = "根据表单id获取表单字段配置信息",description = "根据表单id获取表单字段配置信息")
    @PostMapping(value = "/eduFormEnrollBase0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduFormEnrollParamsBaseVO>> getParamsListByFormId(@RequestBody @Validated EduFormEnrollKeyVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.getParamsListByFormId(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "动态表单字段配置保存",description = "动态表单字段配置保存")
    @PostMapping(value = "/eduFormEnrollBase0012", produces = "application/json;charset=UTF-8")
    public AppResponse saveFormEnrollParams(@RequestBody @Validated SaveFormEnrollParamsBaseVO vo) {
        eduFormEnrollBaseIntegration.saveFormEnrollParams(vo);
        return AppResponse.success();
    }
    @Operation(summary = "获取报名字段模板",description = "获取报名字段模板")
    @PostMapping(value = "/eduFormEnrollBase0015", produces = "application/json;charset=UTF-8")
    public AppResponse<TreeRetVO> getFormEmrollPramTreeList(@RequestBody @Validated OrgTreeVO vo) {
        return AppResponse.successData(eduFormEnrollBaseIntegration.getFormEmrollPramTreeList(vo));
    }

    @Operation(summary = "复制上一年度数据",description = "获取报名字段模板")
    @PostMapping(value = "/eduFormEnrollBase0016", produces = "application/json;charset=UTF-8")
    public AppResponse copyLastYearData(@RequestBody @Validated OrgTreeVO vo) {
        eduFormEnrollBaseIntegration.copyLastYearData(vo);
        return AppResponse.success();
    }
}
